Fix/creative packet lores#246
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Bukkit server-side packet lore pipeline to modify outgoing item lore via handlers while preserving/restoring the original lore using DataComponents.CUSTOM_DATA instead of the previous prefix-based approach.
Changes:
- Reworked clientbound packet listeners to return new packet instances with copied/updated
ItemStacks. - Switched lore cleanup/restoration to snapshot original
ItemLoreintoCUSTOM_DATAand restore it onServerboundSetCreativeModeSlotPacket. - Replaced synchronized fastutil maps with
ConcurrentHashMap-based handler registries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/packet/lore/PacketLoreListener.kt | Replaces prefix-based lore tagging with CUSTOM_DATA snapshot/restore and returns updated packet copies for clientbound inventory packets. |
| gradle.properties | Bumps project version from 1.21.11-2.63.0 to 1.21.11-2.63.1. |
Comment on lines
95
to
+105
| val updatedNmsLore = ItemLore( | ||
| lore.asSequence() | ||
| mutableLore.asSequence() | ||
| .map { it.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE) } | ||
| .map { it.toNms() } | ||
| .map { lorePrefix.copy().append(it) } | ||
| .toList() | ||
| ) | ||
|
|
||
| item.set(DataComponents.LORE, updatedNmsLore) | ||
| CustomData.update(DataComponents.CUSTOM_DATA, item) { tag -> | ||
| tag.store(ORIGINAL_LORE_KEY.asString(), ItemLore.CODEC, nmsLore) | ||
| } |
Comment on lines
48
to
+55
| @ClientboundListener | ||
| fun onContainerData(event: ClientboundContainerSetSlotPacket) { | ||
| makeUpdatedItemStack(event.item) | ||
| fun onContainerData(event: ClientboundContainerSetSlotPacket): ClientboundContainerSetSlotPacket { | ||
| return ClientboundContainerSetSlotPacket( | ||
| event.containerId, | ||
| event.stateId, | ||
| event.slot, | ||
| makeUpdatedItemStack(event.item.copy()) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the
PacketLoreListenerin the Bukkit server module, focusing on how item lore is handled in Minecraft packet events. The changes modernize the code, make lore handling more robust, and ensure original lore is preserved and restored correctly.Lore handling improvements
ConcurrentHashMapforloreHandlersandloreHandlersGlobal, improving thread safety and performance.ORIGINAL_LORE_KEY) and Minecraft'sCustomDataAPI, ensuring the original lore can be restored after modifications.Packet event handler updates
Code cleanup and modernization
gradle.propertiesto1.21.11-2.63.1.